home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 October: Mac OS SDK / Dev.CD Oct 97 SDK1.toast / Development Kits (Disc 1) / QuickDraw GX / Programming Stuff / Sample Code / Printing Samples / Applications… / QuickDraw GX Aware Sample ƒ / Simple Sample ƒ / main.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-06-14  |  3.1 KB  |  136 lines  |  [TEXT/MMCC]

  1. /*********************************************************************
  2.  
  3.     main.c
  4.     
  5.     This file contains the main code and initialization routines for
  6.     the QuickDraw GX unaware sample, "Simple Sample."
  7.     
  8.     Additional info can be found in the related develop #19 article,
  9.     "Adding QuickDraw GX Printing to QuickDraw Applications."
  10.  
  11.     Dave Hersey, Apple Developer Technical Support.
  12.     
  13.     ——————— Edit Trail ———————
  14.     
  15.     creation:                                        1/22/94  - dmh
  16.     cleaned up for 2nd draft of develop article:    3/10/94  - dmh
  17.     cleaned up for final:                            4/14/94  - dmh
  18.     Updated to support Universal Interfaces 2.1:    6/14/96  - cn
  19.     
  20. *********************************************************************/
  21.  
  22. #include "Simple Sample.h"
  23.  
  24. Rect                 gWindowRect = {50, 15, 512, 510};    // Our window size.
  25. short                 gAppResRefNum;                        // Our app's resource file refNum.
  26. long                gSleep = 0;                            // Sleep value for WaitNextEvent.
  27. Boolean                gQuitAfterPrinting = true;            // Quit after handling 'pdoc'?
  28. Boolean                gQuitting;                            // Quitting?
  29. Boolean                gSystemSevenIsPresent;                // System 7.0 or later is available?
  30.  
  31.  
  32. /************************************************************
  33.   MyInitialize - This routine performs the standard Mac
  34.   toolbox initialization.
  35.  
  36. *************************************************************/
  37.  
  38.  void MyInitialize()
  39.  {
  40.     CursHandle        theCurs; 
  41.     Handle            menuBar;
  42.  
  43. //    We're not quitting, and we don't have a print dialog displayed.
  44.  
  45.     gQuitting = false;
  46.  
  47. //    Initialize.
  48.  
  49.     InitGraf(&qd.thePort);
  50.     InitFonts();
  51.     InitWindows();
  52.     InitMenus();
  53.     InitCursor();
  54.  
  55. /*
  56.     See what system software is available.  If we don't have
  57.     what we need, bail.
  58. */
  59.     MyCheckConfig();
  60.     
  61.     if (!gSystemSevenIsPresent)
  62.     {
  63.         Alert(r_BadConfig, nil);
  64.         gQuitting = true;
  65.         return;
  66.     }
  67.  
  68. /*
  69.     Change to a watch cursor while we set up our menu bar
  70.     and then install our AppleEvent handlers.
  71. */
  72.     theCurs = GetCursor(watchCursor);
  73.     SetCursor(*theCurs);
  74.  
  75.     menuBar = GetNewMBar(rMenuBar);
  76.  
  77.     if (menuBar)
  78.     {
  79.         SetMenuBar(menuBar);
  80.         DisposHandle(menuBar);
  81.         AddResMenu(GetMHandle(mApple), 'DRVR');
  82.         DrawMenuBar();
  83.         SetCursor(&qd.arrow);
  84.  
  85.         MyDoAEInstallation();
  86.     }
  87. }
  88.  
  89.  
  90. /************************************************************
  91.   MyCheckConfig - This routine sets up our global
  92.   configuration variables based on results from Gestalt.
  93.  
  94. *************************************************************/
  95.  
  96. void MyCheckConfig()
  97. {
  98.     long    sysVersion;
  99.  
  100. //    Get the system version and see if it's 7.0 or later.
  101.  
  102.     gSystemSevenIsPresent = false;
  103.     
  104.     if (Gestalt(gestaltSystemVersion, &sysVersion) == noErr)
  105.         if (sysVersion >= 0x0700) gSystemSevenIsPresent = true;
  106. }
  107.  
  108.  
  109. /************************************************************
  110.   main - This is our main routine.  Not much else to say…
  111.  
  112. *************************************************************/
  113.  
  114. void main()
  115. {        
  116.     WindowPtr    wind;
  117.     char        i;
  118.  
  119.     gAppResRefNum = CurResFile();
  120.     MaxApplZone();
  121.     for (i = 1; i <= 6; i++)
  122.         MoreMasters(); 
  123.  
  124. //    Initialize the managers and jump into our event loop.
  125.  
  126.     MyInitialize();    
  127.  
  128.     while (!gQuitting)
  129.         MyEventLoop();
  130.  
  131. //    Leaving.  Close all the windows we opened.
  132.  
  133.     while (wind = FrontWindow())
  134.         MyDisposeDocument(MyGetDocPtr(wind));
  135. }
  136.